{extend name="../../common/view/admin_base"/}

{block name="main"}
<link rel="stylesheet" href="__static__/layui/extend/dtree/dtree.css">
<link rel="stylesheet" href="__static__/layui/extend/dtree/font/dtreefont.css">
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-form">
                        <div class="layui-form-item layui-hide">
                            <label class="layui-form-label">id</label>
                            <div class="layui-input-inline" style="width:260px;">
                                <input type="text" name="form[id]" value="{$model.id|default=''}" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-input-inline" style="width:260px;">
                                <input type="text" name="form[username]" value="{$model.username|default=''}" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">真实姓名</label>
                            <div class="layui-input-inline" style="width:260px;">
                                <input type="text" name="form[username]" value="{$model.username|default=''}" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">性别</label>
                            <div class="layui-input-block">
                                <input type="radio" name="form[sex]" value="0" title="男" {$model.sex?"":"checked"} >
                                <input type="radio" name="form[sex]" value="1" title="女" {$model.sex?"checked":""}>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">密码</label>
                            <div class="layui-input-inline">
                                <input type="text" name="form[password]" value="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">联系方式</label>
                            <div class="layui-input-inline" style="width:300px;">
                                <input type="text" name="form[contact]" value="{$model.contact|default=''}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="commit">提交</button>
                                <button class="layui-btn layui-btn-primary" lay-submit lay-filter="reset">重置</button>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['element','layer', 'table','form'], function() {
        var element = layui.element;
        var layer = layui.layer;
        var form = layui.form;

        form.on('submit(commit)', function(obj){
            $.post({
                url:document.URL
                ,type:'post'
                ,data: obj.field
                ,success:function(res){
                    if(res.code == 1){
                        layer.msg(res.msg, {
                            offset: '15px'
                            ,icon: 1
                            ,time: 1000
                        }, function(){
                            parent.window.frames[0].document.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        });

    });

</script>

{/block}